import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

class LanguageLocalizations {
  final Locale locale;

  LanguageLocalizations(this.locale);

  static LanguageLocalizations of(BuildContext context) {
    return Localizations.of(
        context, LanguageLocalizations);
  }

  static final Map<String, Map<String, String>> _localized = {
    'en': {'title': 'hello'},
    'zh': {'title': '您好'}
  };

  String get title {
    return _localized[locale.languageCode]!['title'] ?? '';
  }
}

class LanguageLocationDelegate
    extends LocalizationsDelegate<LanguageLocalizations> {
  LanguageLocationDelegate();

  @override
  Future<LanguageLocalizations> load(Locale locale) {
    return SynchronousFuture<LanguageLocalizations>(
        LanguageLocalizations(locale));
  }

  @override
  bool isSupported(Locale locale) {
    return true;
  }

  @override
  bool shouldReload(LocalizationsDelegate<LanguageLocalizations> old) {
    return false;
  }
}
